package com.domino.server.user;

import java.lang.reflect.Type;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;

public class JSonUtil {

	public static Map<String, String> decode(String content)  {
		if (content==null) { return null; }
		try {
		Gson gson = new Gson();
		Type mapType = new TypeToken<Map<String,String>>() {}.getType();
		return gson.fromJson(content, mapType);
		} catch (JsonParseException e) {
			return null;
		}
	}
	
	/*public static void main(String [] args) {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("\n");
		sb.append("\"id\": \"758377746\",");
		sb.append("\n");
		sb.append("\"name\": \"Per Segersten\",");
		sb.append("\n");
		sb.append("\"first_name\": \"Per\"");
		sb.append("\n");
		sb.append("}");
		System.out.println(sb.toString());
		System.out.println(decode(sb.toString()));
	}*/

}
